const express = require('express')
const app = express()
const port = 618


app.use(function(req, res, next) {
  res.setHeader('Access-Control-Allow-Origin', '*');
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
  res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization');
  next();
});

//加载中间件
const Mylog = require('./middleware/Mylog')
//使用中间件
app.use(Mylog)
//加载静态资源
app.use('/xugou',express.static("./"))
//加载路由
const Myrouting = require("./routing/Myrouting")
//使用路由
app.use(Myrouting)
//加载404中间件
const My404 = require('./middleware/My404')
//最后执行
app.use(My404)
app.listen(port, () => console.log(`Example app listening on port port!`))